package com.zl.smartmall.library.po;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

/**
 * @author Administrator
 *
 */
public class MaintenacesInfo implements Serializable {
	
	private String repair_apply_id;
	private String code;// 维修编号
	private String repairitem;// 维修项目
	private String address;// 维修地址
	private String applyname;// 维修人
	private String createdat;// 维修时间
	private String status;// 维修状态
	private List<MaintenacesDetail> maindetails;// 维修详情
	private List<EquipmentImage> image;//维修图片
	private String reference_price;//参考维修费
	private String is_charged;//（是否有偿 1 是 0 否）
	private int com_id;
	private int root_id;
	private List<EquipmentComment> comments;

	public String getRepair_apply_id() {
		return repair_apply_id;
	}

	public void setRepair_apply_id(String repair_apply_id) {
		this.repair_apply_id = repair_apply_id;
	}
	public List<EquipmentComment> getComments() {
		return comments;
	}

	public void setComments(List<EquipmentComment> comments) {
		this.comments = comments;
	}

	public String getReference_price() {
		return reference_price;
	}

	public void setReference_price(String reference_price) {
		this.reference_price = reference_price;
	}

	public String getIs_charged() {
		return is_charged;
	}

	public void setIs_charged(String is_charged) {
		this.is_charged = is_charged;
	}

	public String getCode() {
		return code;
	}

	public String getRepairitem() {
		return repairitem;
	}

	public String getAddress() {
		return address;
	}

	public String getApplyname() {
		return applyname;
	}

	public String getStatus() {
		return status;
	}

	public List<MaintenacesDetail> getMaindetails() {
		return maindetails;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public void setRepairitem(String repairitem) {
		this.repairitem = repairitem;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public void setApplyname(String applyname) {
		this.applyname = applyname;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public String getCreatedat() {
		return createdat;
	}

	public void setCreatedat(String createdat) {
		this.createdat = createdat;
	}

	public void setMaindetails(List<MaintenacesDetail> maindetails) {
		this.maindetails = maindetails;
	}

	
	public List<EquipmentImage> getImage() {
		return image;
	}

	public void setImage(List<EquipmentImage> image) {
		this.image = image;
	}

	private String info;//维修内容
	public String getInfo() {
		return info;
	}

	public void setInfo(String info) {
		this.info = info;
	}

	public int getCom_id() {
		return com_id;
	}


	public void setCom_id(int com_id) {
		this.com_id = com_id;
	}


	public int getRoot_id() {
		return root_id;
	}


	public void setRoot_id(int root_id) {
		this.root_id = root_id;
	}

	public static List<MaintenacesInfo> parse(JSONArray jsonArray)
			throws JSONException {
		List<MaintenacesInfo> mainInfos = new ArrayList<MaintenacesInfo>();
		for (int i = 0; i < jsonArray.length(); i++) {
			MaintenacesInfo mainInfo = new MaintenacesInfo();
			JSONObject jsonObject = jsonArray.getJSONObject(i);
			mainInfo.setRepair_apply_id(jsonObject.getString("repair_apply_id"));
			mainInfo.setCode(jsonObject.getString("code"));
			mainInfo.setRepairitem(jsonObject.getString("repair_item"));
			mainInfo.setAddress(jsonObject.getString("address"));
			mainInfo.setApplyname(jsonObject.getString("apply_name"));
			mainInfo.setCreatedat(jsonObject.getString("created_at"));
			mainInfo.setStatus(jsonObject.getString("status"));
			mainInfo.setInfo(jsonObject.getString("info"));
			mainInfo.setIs_charged(jsonObject.getString("is_charged"));
			mainInfo.setReference_price(jsonObject.getString("reference_price"));
			mainInfo.setMaindetails(MaintenacesDetail.parse(jsonObject.getJSONArray("detail")));
			mainInfo.setComments(EquipmentComment.parse(jsonObject.getJSONArray("evaluation_detail")));
			mainInfo.setImage(EquipmentImage.parse(jsonObject.getJSONArray("images")));
			mainInfo.setCom_id(jsonObject.getInt("com_id"));
			mainInfo.setRoot_id(jsonObject.getInt("root_id"));
			mainInfos.add(mainInfo);

		}
		return mainInfos;
	}

}
